﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MockupDesigner.Editors.TextEditors;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows;

namespace MockupDesigner.Items
{
    [SimpleTextEditor]
    public class CheckBoxRadioButtonItem : ItemBase, ITextItem
    {
        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(CheckBoxRadioButtonItem), new UIPropertyMetadata(string.Empty));

        [Category("Prop_Content")]
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set
            {
                if (this.Text == value) return;
                OnPropertyChanging("Text", this.Text, value);
                SetValue(TextProperty, value);
                OnPropertyChanged("Text");
                this.Width = 14 + value.Length * 11;
            }
        }

        public static new readonly DependencyProperty FlowDirectionProperty =
           DependencyProperty.Register("FlowDirection", typeof(FlowDirection), typeof(CheckBoxRadioButtonItem), new UIPropertyMetadata(FlowDirection.LeftToRight));

        [Category("Prop_Settings")]
        [DisplayName("Text on right")]
        public new FlowDirection FlowDirection
        {
            get { return (FlowDirection)GetValue(FlowDirectionProperty); }
            set
            {
                if (this.FlowDirection == value) return;
                OnPropertyChanging("FlowDirection", this.FlowDirection, value);
                SetValue(FlowDirectionProperty, value);
                OnPropertyChanged("FlowDirection");
            }
        }

        public static readonly DependencyProperty CheckedProperty =
           DependencyProperty.Register("Checked", typeof(bool), typeof(CheckBoxRadioButtonItem), new UIPropertyMetadata(false));

        [Category("Prop_Settings")]
        public bool Checked
        {
            get { return (bool)GetValue(CheckedProperty); }
            set
            {
                if (this.Checked == value) return;
                OnPropertyChanging("Checked", this.Checked, value);
                SetValue(CheckedProperty, value);
                OnPropertyChanged("Checked");
            }
        }

        public bool Multiline
        {
            get { return false; }
            set
            {
                // Nothing to do
            }
        }
    }
}
